package com.xdwanj.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/pet")
public class PetServlet extends HttpServlet {

    /**
     * 根请求地址
     */
    public static final String REQUEST_MAPPING = "pet";

    /**
     * 方法属性名
     */
    public static final String METHOD = "method";

    /**
     * 宠物ID
     */
    public static final String PID = "pid";

    /**
     * 查询动作
     */
    public static final String QUERY_PET_LIST = "queryPetList";

    /**
     * 添加动作
     */
    public static final String ADD_PET = "addPet";

    /**
     * 删除动作
     */
    public static final String DEL_PET = "delPet";

    /**
     * 修改动作
     */
    public static final String UPDATE_PET = "updatePet";


    /**
     * Pet ID
     */
    public static final String PET_ID_LIST = "petIdList";

    /**
     * Pet名字
     */
    public static final String PET_NAME = "petName";

    /**
     * Pet年龄
     */
    public static final String PET_AGE = "petAge";

    /**
     * Pet状态
     */
    public static final String PET_TYPE = "petType";

    /**
     * Pet雌雄
     */
    public static final String PET_SEX = "petSex";

    /**
     * Pet体重
     */
    public static final String PET_WEIGHT = "petWeight";

    /**
     * Pet状态
     */
    public static final String PET_INFO = "petInfo";

    /**
     * Pet绝育状态
     */
    public static final String PET_STERILIZATION = "petSterilization";

    /**
     * Pet 严重程度
     */
    public static final String PET_LEVEL = "petLevel";

    /**
     * Pet 驱虫日期
     */
    public static final String PET_EXPELLINGPARASITEDATE = "petExpellingParasiteDate";

    /**
     * Pet 疫苗史
     */
    public static final String PET_VACHISTORY = "petVacHistory";

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("进入PetServlet...");
        String method = request.getParameter(METHOD);

        switch (method) {
            case QUERY_PET_LIST:
                queryPetList(request, response);
                break;
            case ADD_PET:
                addPet(request, response);
                break;
            case DEL_PET:
                delPet(request, response);
            case UPDATE_PET:
                changePet(request, response);

            default:
                break;
        }
    }

    private void queryPetList(HttpServletRequest request, HttpServletResponse response) {

    }

    private void changePet(HttpServletRequest request, HttpServletResponse response) {

    }

    private void delPet(HttpServletRequest request, HttpServletResponse response) {

    }

    private void addPet(HttpServletRequest request, HttpServletResponse response) {

    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);

    }

}
